import 'package:backend.core/core/domain/entities/web/web_payment_method.dart';
import 'package:backend.core/core/domain/entities/web/web_payment_method_failure.dart';
import 'package:backend.core/core/domain/entities/web/yookassa/yookassa_bank_card_info.dart';
import 'package:equatable/equatable.dart';

class YookassaPaymentMethod extends Equatable implements WebPaymentMethod {
  const YookassaPaymentMethod({
    required this.id,
    required this.userId,
    required this.saved,
    required this.test,
    required this.bankCardInfo,
    required this.failure,
    required this.yookassaApiPaymentMethodId,
  });

  @override
  final String id;

  @override
  final String userId;

  @override
  final bool saved;

  @override
  final bool test;

  @override
  final YookassaBankCardInfo bankCardInfo;

  @override
  final WebPaymentMethodFailure? failure;

  final String? yookassaApiPaymentMethodId;

  @override
  List<Object?> get props {
    return [
      id,
      userId,
      saved,
      test,
      yookassaApiPaymentMethodId,
      bankCardInfo,
    ];
  }

  YookassaPaymentMethod copyWith({
    String Function()? id,
    String Function()? userId,
    bool Function()? saved,
    bool Function()? test,
    YookassaBankCardInfo Function()? bankCardInfo,
    WebPaymentMethodFailure? Function()? failure,
    String? Function()? yookassaApiPaymentMethodId,
  }) {
    return YookassaPaymentMethod(
      id: id == null ? this.id : id(),
      userId: userId == null ? this.userId : userId(),
      saved: saved == null ? this.saved : saved(),
      test: test == null ? this.test : test(),
      bankCardInfo: bankCardInfo == null ? this.bankCardInfo : bankCardInfo(),
      failure: failure == null ? this.failure : failure(),
      yookassaApiPaymentMethodId: yookassaApiPaymentMethodId == null
          ? this.yookassaApiPaymentMethodId
          : yookassaApiPaymentMethodId(),
    );
  }
}
